package com.wanggsx.library.base.mvp;

public abstract class BaseMVPActivity<AF extends BaseMVPActivity,V extends IView, P extends BasePresenter<AF,V>>
        extends BaseActivity {

    private P mPresenter;

    protected void setPresenter() {
        mPresenter = mPresenterCreate();
        if (mPresenter == null) {
            throw new NullPointerException("请把管理者实现类new出来呦");
        }
    }

    protected abstract P mPresenterCreate();

    public P getPresenter(){
        return mPresenter;
    }

    @Override
    protected void onDestroy() {
        mPresenter.detachFragmentOrActivity();
        super.onDestroy();
    }
}
